package test;

import java.util.Scanner;

public class DigitSumCalculator {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        System.out.print("请输入一个整数: ");
        int number = scanner.nextInt();
        int sum = getSumOfDigits(number);
        System.out.println("该整数的各位数字之和为: " + sum);
    }
    public static int getSumOfDigits(int number) {
        int sum = 0;
        while (number!= 0) {
            sum += number % 10;
            number /= 10;
        }
        return sum;
    }
}